package com.example.yiznspringtestinterface.controller;

import com.alibaba.fastjson.JSONObject;
import com.as.yiznspringbootstarter.SplicingService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * project : my-learn
 * <p> 测试controller </p>
 *
 * @author yisl
 * @date 2022-06-07【星期二】
 **/
@RestController
@RequestMapping("/sdyxinterface")
public class TestInterface {

    @Resource
    private SplicingService splicingService;

    @PostMapping(value = "/20190426/login/getToken/123")
    public String preproccess(@RequestBody String bodyJson, HttpServletResponse response) {

        System.out.println("收到请求"+bodyJson);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("msg", "success");
        jsonObject.put("code", "09000");
        JSONObject jsonObject1 = new JSONObject();
        jsonObject1.put("msg", "获取成功！");
        jsonObject1.put("code", "000");
        jsonObject1.put("token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE1NjgwMDI5NTMsImVudElkIjoiRDFEOUdDIn0.n4FXLGKOIUV8Ml_dE2Y51W7lh8hoPMH6Kb1tyuGJ2lpSAV2ASK0_i9PwdT3lJFbA6QSnMCPrBXA0LngsmSwTyQ");
        jsonObject.put("data", jsonObject1);

        //String result = "{\"msg\": \"success\",\"code\": \"09000\",\"data\": {\"msg\": \"获取成功！\",\"code\": \"000\",\"token\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE1NjgwMDI5NTMsImVudElkIjoiRDFEOUdDIn0.n4FXLGKOIUV8Ml_dE2Y51W7lh8hoPMH6Kb1tyuGJ2lpSAV2ASK0_i9PwdT3lJFbA6QSnMCPrBXA0LngsmSwTyQ\"}";

        return jsonObject.toJSONString();

    }
    @PostMapping(value = "/20190426/msg/sendTelMsg/123")
    public String preproccessT(@RequestBody String bodyJson, HttpServletResponse response) {

        System.out.println("收到请求"+bodyJson);
        String result = "{\"msg\":\"success\",\"code\":\"02000\",\"data\":{\"failCount\":0,\"successCount\":3,\"resultList\":[{\"contactId\":\"0629171330100000000081\",\"tel\":\"7XriOZZjl53Cj4kqBqiWHQ==\"}]}}";
        return result;

    }
    @PostMapping(value = "/test")
    public String TestStarter(@RequestBody String bodyJson, HttpServletResponse response) {
        return splicingService.Splicing("china");

    }

}
